package com.zengqingfa.juc.n4.lock8;

import lombok.extern.slf4j.Slf4j;

/**
 * @fileName: ThreadLock3
 * @author: zengqf3
 * @date: 2021-6-10 9:41
 * @description:
 */
@Slf4j(topic = "c.ThreadLock3")
public class ThreadLock3 {

    public synchronized void method1() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.debug("method1....");
    }

    public synchronized void method2() {
        log.debug("method2....");
    }

    public synchronized void method3() {
        log.debug("method3....");
    }

    public static void main(String[] args) {
        ThreadLock3 lock = new ThreadLock3();
        new Thread(() -> {
            lock.method1();
        }).start();
        new Thread(() -> {
            lock.method2();
        }).start();
        new Thread(() -> {
            lock.method3();
        }).start();

    }
}
